#ifndef _COMMON_
#define _COMMON_

//#pragma comment(lib, "libraries/pthread/pthreadVC2.lib")

#include <allegro.h>
#include <stdio.h>
#include "libraries/pthread/pthread.h"

typedef int bool;
#define true 1
#define false 0
#define M_PI 3.14159265358979323846

#define DIR_STOP  -2
#define DIR_NONE  -1
#define DIR_LEFT  0
#define DIR_RIGHT 1
#define DIR_UP    2
#define DIR_DOWN  3
#define DIR_DEFAULT DIR_DOWN

#define GAME_STATE_PLAY    0
#define GAME_STATE_LOADING 1
#define GAME_STATE_OPTIONS 2
#define GAME_STATE_DEMO    4
#define GAME_STATE_SHOP    8
#define GAME_STATE_MENU    16

#define TIME_PER_CASE 18000
#define FPS 60

#define MULTI_THREADING true

typedef pthread_mutex_t Mutex;
#define Lock(x) pthread_mutex_lock(&x)
#define UnLock(x) pthread_mutex_unlock(&x)
#define lock(mutex,command) {Lock(mutex);command;UnLock(mutex);}

extern int oldState;
extern int gameState;
extern int stateTime;

extern int loadState;

extern int stretching;
extern int lDiff, rDiff, tDiff, bDiff;

extern int buying;
extern int shopChoice;
extern int selling;
extern int mustExit;

extern int capital;

typedef struct
{
    short X;
    short Y;
} COORD;
COORD CreateCoord(int X, int Y);
COORD AddCoord(COORD c1, COORD c2);

int IsEqual(void* m1, void* m2, int size);
#define IsCoordEqual(c1, c2) IsEqual(&c1, &c2, sizeof(COORD))

int fget32(FILE* file);

#endif